<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>条件渲染</title>
    <script src="../js/vue.js"></script>
    <style>
        img{
            width: 100px;
        }
    </style>
</head>
<body>
    <div id="root">
        <h2>今天天气很{{isHot ? '炎热' : '爽凉'}}</h2>
        <button @click="isHot = !isHot">切换条件</button>

        <!-- 只有天气炎热才会显示下面的div -->
        <div v-show="isHot">
            <img src="https://s3.ax1x.com/2020/12/13/reC1IA.jpg" alt=""><br>
            <span>建议: 心静自然凉</span>
        </div>

        <!-- 只有天气凉爽才会显示下面的div -->
        <div v-show="!isHot">
            <img src="https://s3.ax1x.com/2020/12/13/reCaqg.jpg" alt=""><br>
            <span>秋裤来了,它来了</span>
        </div>

        <hr>

        <!-- ---------v-if  节点都被干掉了. -->
        <!-- 使用v-if、 v-else-if v-else 做条件渲染.. -->
         <!-- 只有天气炎热才会显示下面的div -->
         <div v-if="isHot">
            <img src="https://s3.ax1x.com/2020/12/13/reC1IA.jpg" alt=""><br>
            <span>建议: 心静自然凉</span>
        </div>

        <!-- 只有天气凉爽才会显示下面的div -->
        <div v-else>
            <img src="https://s3.ax1x.com/2020/12/13/reCaqg.jpg" alt=""><br>
            <span>秋裤来了,它来了</span>
        </div>
    </div>

    <script>
        new Vue({
            el: '#root',
            data: {
                isHot: false
            }
        })
    </script>
</body>
</html>